<?php
class CommentController extends Zend_Controller_Action
{
    private $model_cmts;
    public function init()
    {
       $this->model_cmts=new Model_Comments();

    }

    public function indexAction()
    {
       $post_id=(int)$this->_getParam('id');
       $this->model_cmts=new Model_Comments();
       $getCom= $this->model_cmts->getComment($post_id);
       $this->view->display_comment=$getCom;
    }

    public function editAction()
    {
        $commentid=(int)$this->_getParam('id');
        $comment_form=new Form_Comment($commentid);

        $values=$this->model_cmts->oneComment($commentid);
        $comment_form->populate($values);
        $this->view->comment_form=$comment_form;

        if ($this->getRequest()->isPost()) {
            
            if ($comment_form->isValid($this->getRequest()->getPost())) {
                $this->model_cmts->updateComment($this->getRequest()->getPost());

            } else {
                $this->view->message="Not Updated!.";
            }
        }
    }

    public function deleteAction()
    {
       $com_id=(int)$this->_getParam('id');
       $this->model_cmts->deleteComment($com_id);
    }

}





